---
title: "SSRM - Single Row Updates"
enterprise: true
---

This section demonstrates updating rows directly while using the Server-Side Row Model (SSRM).

## Updating Rows API

You can update a single row by using the row node `updateData` or `setData` functions.

{% apiDocumentation source="row-object/properties.json" section="data" names=["updateData", "setData"] /%}

{% note %}
Setting row data will NOT change the row node ID, so if you are using `getRowId()`
and the data changes such that the ID will be different, the `rowNode` will not have its ID updated.
{% /note %}

## Updating Rows Example

The example below demonstrates a basic example, using the API's `forEachNode` function to iterate over all loaded nodes, and updating their version.

* **Set Data:** Sets the row data using `setData` and the grid refreshes the row, notably the cells won't flash with `enableCellChangeFlash`.

* **Update Data:** Updates the row data using `updateData` and the grid refreshes the row, notably the cells do flash with `enableCellChangeFlash`.

{% gridExampleRunner title="Updating All Rows" name="updating-all-rows"  exampleHeight=615 /%}

## Specific Row Updates

The following code snippet outlines the general approach of iterating through all loaded row nodes and then updating target rows with `rowNode.updateData(data)`:

```{% frameworkTransform=true %}
api.forEachNode(rowNode => {
    if (idsToUpdate.indexOf(rowNode.data.id) >= 0) {
        // arbitrarily update some data
        const updated = rowNode.data;
        updated.gold += 1;

        // directly update data in rowNode
        rowNode.updateData(updated);
    }
});
```

The example below demonstrates this snippet in action;

{% gridExampleRunner title="Updating Specific Rows" name="updating-specific-rows"  exampleHeight=615 /%}

## Selected Row Updates

The example below demonstrates how to update all of the rows which the user has selected, note the following:

* The **Update Selected Rows** button will update the row version directly on the selected row nodes.
* The selected nodes are obtained using the `api.getSelectedNodes()` api, and are then individually updated.

{% gridExampleRunner title="Updating Selected Rows" name="updating-selected-row"  exampleHeight=615 /%}

## Next Up

Continue to the next section to learn how to use [Transactions](./server-side-model-updating-transactions/) with the SSRM.
